//
//  BRAPI.m
//  BrezzeSaaS
//
//  Created by IOS on 2021/8/30.
//  Copyright © 2021 Brezze GWG. All rights reserved.
//

#import "BRAPI.h"

@implementation BRAPI

+ (NSString *)homeMain {
    return @"";
}

+ (NSString *)countryList {
    return @"/api/login/country";
}

+ (NSString *)verificationCode {
    return @"/api/login/verification-code";
}

/// 发送手机登录验证码（新接口）
+ (NSString *)sendMobileLoginCode {
    return @"/sw/app/mobile/login/send_code";
}

/// 手机号验证码登录（新接口）
+ (NSString *)mobileLogin {
    return @"/sw/app/mobile/login";
}

+ (NSString *)login {
    return @"/api/login";
}
+ (NSString *)faceIDLogin {
    return @"/api/login/login-token";
}

+ (NSString *)faceIDSave {
    return @"/api/users";
}

+ (NSString *)logout {
    return @"/api/login/log-out";
}

+ (NSString *)platforms {
    return @"/api/login/platforms";
}
+ (NSString *)platformSwitch {
    return @"/api/users/platform-switch";
}

+ (NSString *)appVersion {
    return @"/api/login/version";
}

+ (NSString *)userInfo {
    return @"/api/users/center";
}

/// 获取用户信息（新接口）
+ (NSString *)userCenterInfo {
    return @"/sw/app/ucenter/index.html/V2";
}

// 接口已废弃
//+ (NSString *)languageSwitch:(NSString *)la {
//    return [NSString stringWithFormat:@"/api/users/language-switch/%@",la];
//}

+ (NSString *)configs {
    return @"/api/common/configs";
}

+ (NSString *)editUserInfo {
    return @"/api/users";
}

/// 修改昵称（新接口）
+ (NSString *)editNickname {
    return @"/sw/app/userinfo/edit_nickname";
}

+ (NSString *)orderBilling {
    return @"/api/orders/billing";
}

+ (NSString *)lostSum:(NSString *)orderNo {
    return [NSString stringWithFormat:@"/api/orders/calculate-price/%@",orderNo];
}

+ (NSString *)orderIng {
    return @"/api/orders/ing";
}

+ (NSString *)canRent {
    return @"/api/users/rent-or-not";
}

+ (NSString *)rentboxShowV2:(NSString *)deviceId {
    return [NSString stringWithFormat:@"/sw/app/rentbox/show.html/V2?deviceId=%@", deviceId];
}

+ (NSString *)rentboxPopup:(NSString *)deviceId {
    return [NSString stringWithFormat:@"/sw/app/rentbox/popup?deviceId=%@", deviceId];
}

+ (NSString *)preRent {
    return @"/api/orders/credit-rent";
}

+ (NSString *)createZaloPayOrder:(NSString *)deviceId powerBankType:(NSInteger)powerBankType {
    return [NSString stringWithFormat:@"/sw/app/security/zalopay/V2?deviceId=%@&powerBankType=%ld", deviceId, (long)powerBankType];
}

+ (NSString *)createMoMoPayOrder:(NSString *)deviceId powerBankType:(NSInteger)powerBankType {
    return [NSString stringWithFormat:@"/sw/app/security/momopay/V2?deviceId=%@&powerBankType=%ld", deviceId, (long)powerBankType];
}

+ (NSString *)checkPayOrder:(NSString *)orderUuid {
    return [NSString stringWithFormat:@"/sw/app/security/pay/check?orderUuid=%@", orderUuid];
}

+ (NSString *)getSecurityPayConfig:(NSInteger)powerBankType {
    return [NSString stringWithFormat:@"/sw/app/security_pay/configV2?powerBankType=%ld", (long)powerBankType];
}

+ (NSString *)checkRefund {
    return @"/api/users/refund-judge";
}

+ (NSString *)refundDeposit {
    return @"/api/users/refund-deposit";
}

+ (NSString *)cardPayList:(NSInteger)type amount:(CGFloat)amount {
    return [NSString stringWithFormat:@"/api/users/paymentMethod/%ld/%.2f",type,amount];
}

+ (NSString *)rentResult:(NSString *)orderNo {
    return [NSString stringWithFormat:@"/api/orders/rent-result/%@",orderNo];
}

+ (NSString *)rent:(NSString *)cabinetNo {
    return [NSString stringWithFormat:@"/api/orders/rent/%@",cabinetNo];
}

+ (NSString *)filesUpload {
    return @"/api/common/files/upload";
}

+ (NSString *)filesDelete {
    return @"/api/common/files";
}

+ (NSString *)filesDownload {
    return @"/api/common/files/download";
}

+ (NSString *)faqList {
    return @"/api/faqs";
}

+ (NSString *)feedback {
    return @"/api/feedback";
}

+ (NSString *)feedbackSwap {
    return @"/api/feedback/buy-pb";
}

+ (NSString *)reportDamage {
    return @"/api/orders/question/damage";
}

+ (NSString *)checkOrder:(NSString *)order {
    return [NSString stringWithFormat:@"/api/orders/question/%@",order];
}

+ (NSString *)reportOrderProblem  {
    return @"/api/orders/question/order-problem";
}

+ (NSString *)getWallet {
    return @"/api/users/wallet";
}

+ (NSString *)receipts {
    return @"/api/users/receipts";
}

+ (NSString *)userTransfer:(NSInteger)offset {
    return [NSString stringWithFormat:@"/api/users/transfer/%ld",offset];
}

+ (NSString *)defaultCard {
    return @"/api/users/bankcard-default";
}

+ (NSString *)deleteCard:(NSString *)cardID {
    return [NSString stringWithFormat:@"/api/users/bankcard/%@",cardID];
}

+ (NSString *)OrderList:(NSInteger)offset {
    return [NSString stringWithFormat:@"/api/orders/list/%ld",offset];
}

/// 订单列表（新接口）
+ (NSString *)orderListV2 {
    return @"/sw/app/rentbox/order/list.html/V2";
}

+ (NSString *)swapList:(NSInteger)offset {
    return [NSString stringWithFormat:@"/api/orders/swap/list/%ld",offset];
}

+ (NSString *)OrderDetail:(NSString *)orderNo {
    return [NSString stringWithFormat:@"/api/orders/%@",orderNo];
}

+ (NSString *)OrderDetailV2:(NSInteger)orderId {
    return [NSString stringWithFormat:@"/sw/app/rentbox/order/detail.html/V2?orderId=%ld", (long)orderId];
}

+ (NSString *)OrderSwapDetail:(NSString *)orderNo {
    return [NSString stringWithFormat:@"/api/orders/swap/detail/%@",orderNo];
}

+ (NSString *)stationNear {
    return @"/api/branches/";
}

+ (NSString *)stationNearV2:(CGFloat)lng lat:(CGFloat)lat distance:(NSInteger)distance total:(NSInteger)total {
    return [NSString stringWithFormat:@"/sw/app/site/around/list/V2?lng=%.8f&lat=%.8f&distance=%ld&total=%ld", lng, lat, (long)distance, (long)total];
}

+ (NSString *)stationDetail {
    return @"/api/branches/";
}

+ (NSString *)stationDetailV2:(NSInteger)siteId distance:(CGFloat)distance {
    return [NSString stringWithFormat:@"/sw/app/site/detail.html/V2?siteId=%ld&distance=%.8f", (long)siteId, distance];
}



#pragma mark - 支付 --
+ (NSString *)paymentMrthod:(NSNumber *)type amount:(NSNumber *)amount {
    return [NSString stringWithFormat:@"/api/users/paymentMethod/%@/%@",type,amount];
}

+ (NSString *)pay {
    return @"/api/users/payment";
}

+ (NSString *)bankcaerd {
    return @"/api/users/bankcard";
}

+ (NSString *)payPriceCalculate {
    return @"/api/orders/calculate-price";
}
#pragma mark - Merchant 接口 --
/// 商户列表
+ (NSString *)merchantList {
    return @"/api/merchants";
}
+ (NSString *)merchant {
    return @"/api/merchants/home";
}
+ (NSString *)withdrawalAmount {
    return @"/api/merchants/withdraws";
}
+ (NSString *)withdrawalAccount {
    return @"/api/merchants/bankcard";
}
+ (NSString *)merchantRentOrder {
    return @"/api/merchants/rental-order";
}
+ (NSString *)merchantBrokerages {
    return @"/api/merchants/brokerages";
}
+ (NSString *)merchantBrokeragesNum {
    return @"/api/merchants/brokerages/summary";
}
+ (NSString *)recordWithdraws {
    return @"/api/merchants/withdraws";
}

+ (NSString *)shopInfo {
    return @"/api/merchants";
}

+ (NSString *)myDevices {
    return @"/api/merchants/cabinets";
}

+ (NSString *)indutstry {
    return @"/api/common/industries";
}

+ (NSString *)checkCurrAccount {
    return @"/api/users/verification-account";
}
+ (NSString *)shopInvite:(NSString *)ciphertext {
    return [NSString stringWithFormat:@"/api/users/branch-owner/invite/%@",ciphertext];
}

#pragma mark - reward 接口 --
+ (NSString *)couponsList {
    return @"/reward/coupons";
}
+ (NSString *)myCouponsList {
    return @"/reward/coupons/my";
}
+ (NSString *)myPromoList {
    return @"/reward/promo-code/my";
}
+ (NSString *)redeemCoupons {
    return @"/reward/coupons/redeem/point";
}

+ (NSString *)orderCoupons {
    return @"/reward/coupons/order";
}

+ (NSString *)myPoints {
    return @"/reward/points/my";
}

+ (NSString *)pointHistory {
    return @"/reward/points";
}

+ (NSString *)pointRule {
    return @"/reward/points/rule";
}

+ (NSString *)promoCodeRedeem {
    return @"/reward/promo-code/redeem";
}

+ (NSString *)promoCodeHistory {
    return @"/reward/promo-code/redeem-history";
}

+ (NSString *)inviteCode:(NSString *)code {
    return [NSString stringWithFormat:@"/reward/invitation/invite/%@",code];
}
+ (NSString *)inviteReward {
    return @"/reward/invitation/reward";
}
+ (NSString *)inviteHistory {
    return @"/reward/invitation/user-reward";
}

+ (NSString *)chargeCards {
    return @"/reward/charge-cards";
}
+ (NSString *)chargeCardsMy {
    return @"/reward/charge-cards/my";
}

+ (NSString *)codeScanRedeem {
    return @"/reward/coupons/scan";
}

#pragma mark - 上传 --
// TODO: 暂时注释掉上传功能，当前app不需要上传功能
+ (void)uploadFiles:(NSData *)data beginBlock:(void(^)(void))beginBlock successBlock:(void(^)(NSURLSessionDataTask *_Nonnull task,id _Nullable responseObject))successBlock failureBlock:(void(^)(NSURLSessionDataTask *_Nullable task, NSError *_Nonnull error))failureBlock {
    // 功能已暂时禁用
    NSLog(@"⚠️ uploadFiles 功能已暂时禁用");
    if (failureBlock) {
        NSError *error = [NSError errorWithDomain:@"BRAPI" code:-1 userInfo:@{NSLocalizedDescriptionKey: @"上传功能已暂时禁用"}];
        failureBlock(nil, error);
    }
}

+ (void)requestUpLoadImgHttpWithData:(NSData *)data AndType:(NSString *)type BeginBlock:(void(^)(void))beginBlock SuccessBlock:(void(^)(NSURLSessionDataTask *_Nonnull task,id _Nullable responseObject))successBlock FailureBlock:(void(^)(NSURLSessionDataTask *_Nullable task, NSError *_Nonnull error))failureBlock {
    // 功能已暂时禁用
    NSLog(@"⚠️ requestUpLoadImgHttpWithData 功能已暂时禁用");
    if (failureBlock) {
        NSError *error = [NSError errorWithDomain:@"BRAPI" code:-1 userInfo:@{NSLocalizedDescriptionKey: @"上传功能已暂时禁用"}];
        failureBlock(nil, error);
    }
}

#pragma mark - 下载视频
// TODO: 暂时注释掉下载功能，当前app不需要下载功能
/**
 下载视频
 @param urlStr 路径
 */
+ (void)requestDownloadWithUrlstring:(NSString *)urlStr {
    // 功能已暂时禁用
    NSLog(@"⚠️ requestDownloadWithUrlstring 功能已暂时禁用: %@", urlStr);
}

//videoPath为视频下载到本地之后的本地路径
+ (void)saveVideo:(NSString *)videoPath{
    
    if (videoPath) {
        
        NSURL *url = [NSURL URLWithString:videoPath];
        
        BOOL compatible = UIVideoAtPathIsCompatibleWithSavedPhotosAlbum([url path]);
        
        if (compatible) {
            
            //保存相册核心代码
            UISaveVideoAtPathToSavedPhotosAlbum([url path], self, @selector(savedPhotoImage:didFinishSavingWithError:contextInfo:), nil);
        }
    }
}

//保存视频完成之后的回调
+ (void)savedPhotoImage:(UIImage*)image didFinishSavingWithError: (NSError *)error contextInfo: (void *)contextInfo {
    
    if (error) {
        
        NSLog(@"保存视频失败%@", error.localizedDescription);
    }
    else {
        NSLog(@"保存视频成功");
    }
    
}


//文件-删除
// TODO: 暂时注释掉文件删除功能，当前app不需要删除功能
+ (void)requestDeleteWithUrlstring:(NSString *)urlStr succeed:(BRAPISucceedBlock)succeed failed:(BRAPIFailed)failed{
    // 功能已暂时禁用
    NSLog(@"⚠️ requestDeleteWithUrlstring 功能已暂时禁用: %@", urlStr);
    if (failed) {
        NSError *error = [NSError errorWithDomain:@"BRAPI" code:-1 userInfo:@{NSLocalizedDescriptionKey: @"删除功能已暂时禁用"}];
        failed(error);
    }
}

@end
